﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;


namespace Sistema.Util
{
    public class InteragirPHP
    {
        
            
            public static String InteracaoWeb(String dado)
            {
                
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.r2ms.com.br/danfe.php");
                request.Method = "POST";
                request.ServicePoint.Expect100Continue = false;
                string postData = dado;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = byteArray.Length;
                request.AllowAutoRedirect = true;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
               
                dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);

                string responseFromServer = reader.ReadToEnd();

                reader.Close();
                dataStream.Close();
                response.Close();

                return responseFromServer;
            }
        }

    }


